<?
session_start();

include('./../config/db_settings.php');
include('pms_inc.php');

$user = $_SESSION[$settings['session_prefix'].'user_id'];

//Are they logged in or not?
if(!$user)
{
	echo "You are not logged in yet. Please login first.";
}
else
{
	$error = '';
	if(mysql_error()==""){
		$names = trim(urldecode($_POST['names']));
		if(strlen($names)==0){
			echo "<b>Please enter at least one user name.</b><br>";
			exit;
		}
		$users = split(";", $names);
		foreach($users as $user){
			$user = trim($user);
			if(strlen($user)>0){
				$sql = mysql_query ("SELECT count(*) user_count FROM ".$db_settings['userdata_table']." WHERE lower(user_name) = '".mysql_real_escape_string(strtolower($user))."'");
				$row = mysql_fetch_array ($sql);
				$user_count = $row['user_count'];
				if($user_count==0){
					$error = $error."<b>".$user."</b> is not a valid user name.<br/>";
				}
			}
		}
		if(strlen($error)==0)
		{
			echo "<b>All the usernames are valid.</b><br>";
		}else
		{
			echo $error;
		}
	}else
	{
		echo "Sorry, there is a database error.";
	}
}
?>

